package tutorial.java.dragdrop;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JProgressBar;
import javax.swing.JButton;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class ProgressBar extends JFrame {

	private JPanel contentPane;
	private JProgressBar progressBar;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					ProgressBar frame = new ProgressBar();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public ProgressBar() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		progressBar = new JProgressBar();
		progressBar.setBounds(121, 101, 146, 14);
		contentPane.add(progressBar);
		
		JButton btnButton = new JButton("Button");
		btnButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				int value = 0;
				value = progressBar.getValue() + 10;
				if (value > progressBar.getMaximum()) {
					value = progressBar.getMaximum();
				}
				progressBar.setValue(value);
			}
		});
		btnButton.setBounds(149, 126, 89, 23);
		contentPane.add(btnButton);
		
		progressBar.setStringPainted(true);
		progressBar.setForeground(Color.RED);
	}
}
